<?php
require_once ('functions.php');
if (isset ($_POST['logindb'])){
connectlogin();
$logindbsetup = mysql_query("ALTER TABLE account_data
ADD fname VARCHAR(30) AFTER expire,
ADD lname VARCHAR(30) AFTER fname,
ADD email VARCHAR(40) AFTER lname,");
$con = mysql_connect("".MYSQL_HOST."","".MYSQL_USER."","".MYSQL_PASS."");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

if (mysql_query("CREATE DATABASE ".MYSQL_BASE_SHOP."",$con))
  {
	  mysql_query("
	  DROP TABLE IF EXISTS `cart`;
		CREATE TABLE `cart` (
 		 `id` int(11) NOT NULL AUTO_INCREMENT,
 		 `player` int(11) NOT NULL,
 		 `item` int(11) NOT NULL,
 		 `account` int(11) NOT NULL,
 		 `price` int(11) NOT NULL,
 		 `active` int(11) NOT NULL,
		  PRIMARY KEY (`id`)
		) ENGINE=InnoDB DEFAULT CHARSET=latin1;
		DROP TABLE IF EXISTS `history`;
CREATE TABLE `history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `account` int(11) NOT NULL,
  `player` int(11) NOT NULL,
  `item` int(11) NOT NULL,
  `price` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `items`;
CREATE TABLE `items` (
  `id` int(60) NOT NULL AUTO_INCREMENT,
  `name` varchar(23) NOT NULL,
  `code` int(23) NOT NULL,
  `price` int(23) NOT NULL,
  `amount` int(23) NOT NULL,
  `race` varchar(23) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `paypal`;
CREATE TABLE `paypal` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tranid` int(11) NOT NULL,
  `amount` int(11) NOT NULL,
  `fee` int(11) NOT NULL,
  `userid` int(11) NOT NULL,
  `name` int(11) NOT NULL,
  `credits` int(11) NOT NULL,
  `time` int(11) NOT NULL,
  `payerid` int(11) NOT NULL,
  `payeremail` varchar(60) NOT NULL,
  `verified` int(11) NOT NULL,
  `dupetran` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `settings`;
CREATE TABLE `settings` (
  `id` int(60) NOT NULL AUTO_INCREMENT,
  `sitename` varchar(60) DEFAULT NULL,
  `theme` varchar(60) DEFAULT NULL,
  `transition` int(2) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
	  ");
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }

mysql_close($con);
}
else 
{
echo "Welcome to Setup I dont work yet but I will soon!!";

}
?>